<?php
/** Zend_Controller_Action */
class Forum_ViewController extends Zend_Controller_Action
{
    public function init()
    {
		//fonctionnalities:
		//get the number of views for a subject (thus forum)
		//get the number of answers for a subject (thus forum)
		/*

$table  = new table_quelquechose();
$row = $table-&gt;fetchRow('bug_status = "NEW"', 'bug_id ASC');
$row = $table-&gt;fetchRow($table-&gt;select()-&gt;where('bug_status = ?', 'NEW')
                                        -&gt;order('bug_id ASC'));
		 * 
		 */
    	
    }
    
	//add or update a forum
    public function forumAddAction()
    {    	
    	$forums = new Forum();
    	$forums->add($this->getRequest()->getPost());
    }
    
	//get top things forums
    public function forumTopAction()
    {    	
    	$forums = new Forum();
    	$this->view->message = $forums->getTop($this->_getParam('top'),$this->_getParam('limit'));
    }
    
    //show list of all subjects of a given forum
    public function subjectAction()
	{
		$subject = new Subject($this->_getParam('forum'));
		$this->view->subjects =   $subject->getAll(); 
    }
    
    //add or update a subject
    public function subjectAddAction()
    {    	
    	$subject = new Subject();
    	$subject->add($this->getRequest()->getPost());
    }

	//get top things subjects
    public function subjectTopAction()
    {    	
    	$subject = new Subject();
    	$this->view->message = $subject->getTop($this->_getParam('top'),$this->_getParam('limit'));
    }
    
    //show all messages of a given subject  
    public function messageAction()
    {
    	$messages = new Message($this->_getParam('subject'));
		$this->view->messages =   $messages->getAll(); 
    }

    //add or update a message
    public function messageAddAction()
    {    	
    	$messages = new Message();
    	$messages->add($this->getRequest()->getPost());
    }

	//get top things messages
    public function messageTopAction()
    {    	
    	$messages = new Message();
    	$this->view->message = $messages->getTop($this->_getParam('top'),$this->_getParam('limit'));    	
    }
    
}